import java.io.*;
import java.util.*;

public class Main {
	String input;
	StringTokenizer st;
	BufferedReader br;
	StringBuilder sb;
	
	final char A = 'A',
			   Z = 'Z',
			   a = 'a',
			   z = 'z';
	long diff;
	int encode;
	
	public Main() {
		br = new BufferedReader(new InputStreamReader(System.in));
		sb = new StringBuilder();
	}
	
	public static void main(String[] args) throws IOException {
		Main main = new Main();
		main.beginProcess();
	}

	void beginProcess() throws IOException {
		input = br.readLine();
		st = new StringTokenizer(input);
		diff = Long.parseLong(st.nextToken());
		diff %= 26;
		
		input = br.readLine();
		st = new StringTokenizer(input);
		encode = Integer.parseInt(st.nextToken());
		
		sb.append(diff + "\n" + encode + "\n");
		
		while((input = br.readLine()) != null)
			sb.append(ascii(encode == 1 ? true : false));
		System.out.print(sb);
	}
	
	String ascii(boolean encode) {
		int i;
		long diff;
		char c;
		String result = "";
		
		diff = this.diff;
		if(encode) diff *= -1;
		for(i = 0; i < input.length(); i++) {
			c = input.charAt(i);
			if(c >= A && c <= Z) {
				if(diff < 0) {
					if(c + diff < A) c += diff + 26;
					else c += diff;
				} else {
					if(c + diff > Z) c += diff - 26;
					else c += diff;
				}
			} else if(c >= a && c <= z) {
				if(diff < 0) {
					if(c + diff < a) c += diff + 26;
					else c += diff;
				} else {
					if(c + diff > z) c += diff - 26;
					else c += diff;
				}
			}
			result += c;
		}
		return result + "\n";
	}
	
}